package com.csun.dsms.controller;

import com.csun.dsms.comment.core.annotation.Authorization;
import com.csun.dsms.comment.core.support.CsunMessageSource;
import com.csun.dsms.comment.core.utils.wrapper.WrapMapper;
import com.csun.dsms.comment.core.utils.wrapper.Wrapper;
import com.csun.dsms.model.domain.DsmsScheduleLog;
import com.csun.dsms.model.dto.schedule.ScheduleLogQueryDto;
import com.csun.dsms.service.DsmsScheduleLogService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chisj chisj@foxmail.com
 * @version 1.0.0
 * @date 2021-09-23 15:34
 * @description: 调度日志拦截器
 */
@RestController
@RequestMapping("/scheduleLog")
public class DsmsScheduleLogController {

    @Resource
    private DsmsScheduleLogService dsmsScheduleLogService;
    @Resource
    private CsunMessageSource csunMessageSource;

    /**
     * 查到调度器日志记录 - 分页
     *
     * @param scheduleLogQueryDto   the schedule log query dto
     *
     * @return  the wrapper
     */
    @Authorization
    @PostMapping(value = "/queryListWithPage")
    public Wrapper queryListWithPage(@RequestBody ScheduleLogQueryDto scheduleLogQueryDto) {

        List<DsmsScheduleLog> scheduleLogList = dsmsScheduleLogService.queryListWithPage(scheduleLogQueryDto);

        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, csunMessageSource
                .getMessage("operation.success", null), new PageInfo<>(scheduleLogList));
    }
}
